<table class="table table-bordered table-striped table-condensed">
    <thead>
        <tr>
            <td>Matricule</td>
            <td>Nom</td>
            <td>Prénom</td>
            <td>Date d'entrée</td>
        </tr>
    </thead>
    <tbody>
<?php

$data = isset($_POST['data']) ? $_POST['data'] : null;
if (is_null($data)) {
    echo ("Les données sont NULL");
    die;
}
$lignes = explode(PHP_EOL, $data);

// connexion au serveur
$c = mysql_connect('localhost', 'root', '') or die("Connexion impossible au serveur");
mysql_select_db('cojean_online', $c) or die("Connexion impossible à la base de données");
$sql = "SELECT matricule, nom1, prenom, contrat_debut FROM rh_employe ";
$where = true;
foreach ($lignes as $l){
    $csv = str_getcsv($l, ';');
    if(!isset($csv[0]))        continue;
    if($where){
        $sql .= ' WHERE ';
    }else{
        $sql .= ' OR ';
    }
    $where = false;
    $nom = addslashes($csv[0]);
    $prenom = addslashes($csv[1]);
    $sql .= "(nom1 LIKE '$nom' AND prenom LIKE '$prenom')";
}
//$sql .= ' GROUP BY matricule';
//echo "<pre>$sql</pre>";
$result = mysql_query($sql, $c) or die(mysql_error($c));
while($row = mysql_fetch_assoc($result)):
    ?>
<tr>
    <td><?php echo $row['matricule']; ?></td>
    <td><?php echo utf8_encode($row['nom1']); ?></td>
    <td><?php echo utf8_encode($row['prenom']); ?></td>
    <td><?php echo $row['contrat_debut']; ?></td>
</tr>
<?php
endwhile;
mysql_close($c);
?>
    </tbody>
</table>
